konfiguracjamythtvfandomcom_pl-20200213-history
Instalacja SASC-NG
Opis na razie jest żywcem skopiowany z tej strony. Potem dopiszę swoje uwagi i zmiany. Introduction SASC-NG is a so called "softcam". It's a piece of software which is able to decode satellite feeds. This can be useful in multiple cases: * When your DVB-S(2) device does not have a CI * When you just don't want to buy a CI & CAM (since it is quite expensive) * When you want to share a card over multiple tuners in your system (Perfectly legal, although it may be a breach of contract with your provider) * When you want to participate in cardsharing over the internet (this is, err, less legal) Preparation Got root? Installing everything is much easier when you're root. sudo -s Installing dependencies The following packages are needed to compile sasc-ng. apt-get install linux-headers-`uname -r` build-essential subversion mercurial openssl gettext libssl-dev screen Installing sasc-ng Getting sasc-ng source cd /usr/local/src hg clone http://85.17.209.13:6100/sc cd /usr/local/src/sc chmod +x contrib/sasc-ng/configure chmod +x contrib/sasc-ng/dvbloopback/module/config_dvb.pl Patching the source If the module doesn't want to compile, and you're running a kernel 2.6.32, you need to modify this file: nano /usr/local/src/sc/contrib/sasc-ng/dvbloopback/module/dvb_loopback.c On line 59 there should be this: #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33) #include #endif Change that KERNEL_VERSION to: #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) #include #endif And you're set! Configuring and compiling Do not use --shared! It will cause segfaults. Should you do use it, you'll have to remove your sc folder and try again. (There's no "make clean" here) cd /usr/local/src/sc/contrib/sasc-ng/ ./configure make make module If you compiled your own driver: (else you will get errors like "disagrees about version of symbol ..." when inserting the loopback module) ./configure --dvb-dir=/path/to/driver Installing the dvbloopback module (so it can load at boot) rm /lib/modules/`uname -r`/misc/dvbloopback.ko cd /usr/local/src/sc/contrib/sasc-ng/ cp sasc-ng /usr/bin cp /usr/local/src/sc/contrib/sasc-ng/sc/PLUGINS/lib/* /usr/lib/ mkdir /lib/modules/`uname -r`/misc /usr/bin/install dvbloopback.ko /lib/modules/`uname -r`/misc/ depmod Loading the modules since we installed the module at the appropriate position we can modprobe it: modprobe dvbloopback If you have multiple adapters (like I do, the reason why I'm using sasc-ng) you need to specify the amount of adapters you have. I have 3 adapters, so I do: modprobe dvbloopback num_adapters=3 For some reason I'm constantly getting segfaults on Ubuntu (it doesn't matter what kernel I'm using), but not on Debian. Loading at boot I used to advise you to add a line to your /etc/modules file to load the module at boot. This is no longer necessary with the new runsasc script (which you can find below.) In fact, removing it (therefore putting the script in charge of loading the module) resolved a few headaches for me. Starting sasc-ng To start sasc-ng: LD_LIBRARY_PATH=/usr/local/src/sc/contrib/sasc-ng/sc/PLUGINS/lib/ ./sasc-ng -j 0:1 --cam-budget To use it with MythTV: LD_LIBRARY_PATH=/usr/local/src/sc/contrib/sasc-ng/sc/PLUGINS/lib/ ./sasc-ng -j 0:1 --cam-budget --sid-allpid --sid-nocache LD_LIBRARY_PATH=/usr/local/src/sc/contrib/sasc-ng/sc/PLUGINS/lib/ ./sasc-ng -j 0:3 -j 1:4 -j 2:5 --cam-budget --sid-nocache -d 0xf0a --cam-dir /etc/camfiles To use sasc-ng with newcs, add: cardclient.conf: newcamd:localhost:15000:1/0602/ffff:dummy:dummy:0102030405060708091011121314 Cleaning up Moving files & folders We will give our camfiles (cardclient.conf) a proper home & copy sasc-ng to the binary folder. mkdir /etc/camfiles cd /usr/local/src/sc/contrib/sasc-ng/ mv sc_files/* /etc/camfiles/ cp sasc-ng /usr/bin/ Now we'll move the needed library files to the correct place. cp /usr/local/src/sc/contrib/sasc-ng/sc/PLUGINS/lib/* /usr/lib/ Now we'll edit the startup files. nano /usr/local/bin/runsasc And paste this script (you can ignore the DRIVERDIR variable in this script. Since we copied the module to our kernel tree we can just "modprobe dvbloopback" without any path.) Pay attention to the number of adapters you're loading! I've set it to 3 and have added the necessary "-j" options. #!/bin/bash # Script to automate running of SASC-NG and Drivers # Driver directory DRIVERDIR="/usr/local/src/mythtv.cvs/sasc-ng" # Path to SASC-NG binary SASCPRG="sasc-ng" # Path to CAM Directory CAMDIR="/etc/camfiles/" # Number of DVB Cards you have in your system dedicated to SASC-NG ADAPTERS="3" # Startup Options passed to SASC-NG. Adjust according to your devices. #OPTIONS="-r 0 -v 2 -o" OPTIONS="-j 0:3 -j 1:4 -j 2:5 --cam-budget --sid-allpid --sid-nocache --cam-dir" # Number of times runsasc will attempt to restart SASC-NG after a crash has occured (set to 0 for no limit) MAXTRIES=10 # Minimum runtime required (in seconds) for SASC-NG to continue restart attempts MINRUN=20 ## End Configuration Section ## SASCCMD="$SASCPRG $OPTIONS $CAMDIR" KILL="/usr/bin/killall -q -TERM" # Detect whether the DVBLooopback driver is already loaded # and return 0 if it *is* loaded, 1 if not: function DriverLoaded() { grep -qse dvbloopback /proc/modules } # Load all DVBLoopback driver modules needed for your hardware: function LoadDriver() { modprobe dvbloopback num_adapters=$ADAPTERS sleep 5 } # Unload all DVBLoopback driver modules loaded in LoadDriver(): function UnloadDriver() { rmmod dvbloopback } # Load driver if it hasn't been loaded already: if ! DriverLoaded; then LoadDriver fi LASTRESTART=$(date +%s) LOOPCOUNT=0 while (true) do if [ $LOOPCOUNT -le $MAXTRIES ] || [ $MAXTRIES -eq 0 ] ; then eval "screen -D -m -S sasc-ng $SASCCMD &" # Wait for SASC-NG to initialize then do rest sleep 10 touch /tmp/SASC_COMPLETE else $KILL runsasc fi # Remember PID of SASC-NG process PID=$! # Wait for SASC-NG to end or signal to arrive wait $PID # Remember return value of SASC-NG RET=$? if test $RET -eq 0 -o $RET -eq 2; then exit; fi TIMEOFDEATH=$(date +%s) RUNTIME=$((TIMEOFDEATH - LASTRESTART)) if [ $TIMEOFDEATH -le $(($LASTRESTART + $MINRUN)) ] ; then echo "`date` SASC-NG crashed in $RUNTIME seconds. Minimum required runtime for SASC-NG is $MINRUN seconds. Killing runsasc process..." $KILL runsasc fi echo "`date` Reloading DVBLoopback drivers" $KILL sasc-ng sleep 10 UnloadDriver LoadDriver LASTRESTART=$(date +%s) LOOPCOUNT=$((LOOPCOUNT+1)) echo "`date` Restarting SASC-NG $LOOPCOUNT time(s). Maximum retries set to $MAXTRIES" done And give it the proper permissions: chmod 755 /usr/local/bin/runsasc chmod +x /usr/local/bin/runsasc Init script An init script will take care of sasc-ng starting up at boot. nano /etc/init.d/sascd Add these lines: #! /bin/bash # # sasc start-stop script # PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME="runsasc" DESC="SASC-NG" DAEMON="sasc-ng" ENABLED=0 test -f /etc/default/sascc && . /etc/default/sascc test "$ENABLED" != "0" || exit 0 rm -f /tmp/SASC_COMPLETE LOOP=0 case "$1" in start) if ! ps -C sasc-ng > /dev/null 2>&1; then echo -e "Starting $DESC: $NAME. \n" runsasc & until [ -e /tmp/SASC_COMPLETE ] || [ $LOOP -eq $TIMEOUT ] ; do sleep 1 LOOP=$((LOOP+1)) done if [ $LOOP -eq $TIMEOUT ]; then echo -e "SASC-NG startup sequence has timed out in $TIMEOUT seconds. SASC-NG will not start. \n" exit 1 fi echo -e "SASC-NG startup time was $LOOP second(s). \n" echo -e "SASC-NG startup sequence completed. \n" else echo -e "SASC-NG is already running. \n" fi ;; stop) if ps -C sasc-ng > /dev/null 2>&1; then echo -e "Stopping $DESC: $NAME. \n" sleep 3 killall -q -TERM $NAME killall -q -TERM $DAEMON sleep 5 rmmod dvbloopback.ko else echo -e "SASC-NG is not running. \n" fi ;; restart|force-reload) if ps -C sasc-ng > /dev/null 2>&1; then echo -e "Restarting $DESC: $NAME. \n" sleep 3 killall -q -TERM $NAME killall -q -TERM $DAEMON sleep 5 rmmod dvbloopback.ko sleep 2 runsasc & until [ -e /tmp/SASC_COMPLETE ] || [ $LOOP -eq $TIMEOUT ] ; do sleep 1 LOOP=$((LOOP+1)) done if [ $LOOP -eq $TIMEOUT ]; then echo -e "SASC-NG startup sequence has timed out in $TIMEOUT seconds. SASC-NG will not start. \n" exit 1 fi echo -e "SASC-NG startup time was $LOOP second(s). \n" echo -e "SASC-NG startup sequence completed. \n" else echo -e "SASC-NG is not running. \n" fi ;; *) N=/etc/init.d/$NAME echo "Use: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; esac rm -f /tmp/SASC_COMPLETE exit 0 And now we set the proper permissions and actually add it to the runlevels: chmod +x /etc/init.d/sascd update-rc.d sascd defaults 21 We just need one more config file: nano /etc/default/sascc Add this: # /etc/default/sascc # Default SASC-NG startup config # Change to 1 to enable sasc-ng's init-script ENABLED=1 # DVBLoopback Device creation timeout (in seconds) TIMEOUT=60 Additional files We're planning on using this thing legally, with NewCS in our own system. We need a cardclient.conf file for that: nano /etc/camfiles/cardclient.conf And put this in it. (I added some more lines so you'll get an idea as to how this thing works.) # # Comment lines can start with # or ; # # every client line starts with the client name, followed by some arguments: # 'hostname' is the name of the server # 'port' is the port on the server # 'emm' is a flag to allow EMM transfers to the server # (0=disabled 1=enabled) # 'caid' (optional) caid on which this client should work # 'mask' (optional) mask for caid e.g. caid=1700 mask=FF00 would allow # anything between 1700 & 17FF. # Default is 1700 & FF00. If only caid is given mask is FFFF. # You may give multiple caid/mask values comma separated # (e.g. 1702,1722,0d0c/ff00). # 'username' is the login username # 'password' is the login password # # radegast client #radegast:hostname:port:emm/caid/mask # # aroureos client # 'hexbase' # 'hexserial' card data for which EMM updates should be send #aroureos:hostname:port:emm/caid/mask:hexbase:hexserial # # camd33 client (tcp protocol) # 'aeskey' is the AES key (32bytes), disable encryption if missing #camd33:hostname:port:emm/caid/mask:username:password:aeskey # # camd35 client (udp protocol) #camd35:hostname:port:emm/caid/mask:username:password # # cardd client #cardd:hostname:port:emm/caid/mask:username:password # # buffy client # 'aeskey' is the AES key (32bytes), disable encryption if missing #buffy:hostname:port:emm:username:password:aeskey #some examples #newcamd:192.168.0.10:10000:1/1801/FF00:mythtv:xxxxxxxx:XXXXXXXXXXXXXXXXXXXXXXXXXXXX #radegast:192.168.0.10:10001:1/1801/FF00 # # newcamd client # 'cfgkey' is the config key (28bytes) #newcamd:hostname:port:emm/caid/mask:username:password:cfgKey newcamd:127.0.0.1:10000:1/1801/FF00:test:test:0102030405060708091011121314 # # gbox client # # NOTE: hostname & port will be ignore. GBOX must be runnning on the local # machine. For convinience you should choose localhost:8004 #gbox:hostname:port:emm/caid/mask #newcamd:hostname:port:emm/caid/mask:username:password:cfgKey #newcamd:localhost:15000:1/0602/ffff:dummy:dummy:0102030405060708091011121314 radegast:192.168.1.2:10001:0/0100/ffff